'use strict';

module.exports = function collectSameElements(collectionA, objectB) {
  let result = [];
  for(let i of collectionA){
    let a = Object.keys(i);
    for(let value of i[a]){
      if(ChoosetheSameB(objectB,value)){
        result.push(value);
      }
    }
  }
 
  return result; 
}


function ChoosetheSameB(obj,i){
  for (let a in obj){
    for(let item of obj[a]){
      if(item == i){
        return true;
      }
    }
  }
  return false;
}